import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

export class ProductSpec {
  title: string;
  price: number;
  stock: number;
}

@Entity('tb_product', {
  comment: '商品表',
})
export class Product {
  @PrimaryGeneratedColumn('increment', { comment: '自增主键', unsigned: true })
  id: number;

  @Column({ comment: '商品名称' })
  name: string;

  @Column({ comment: '商品图片' })
  image: string;

  @Column({ comment: '商品标价', unsigned: true })
  price: number;

  @Column({ comment: '商品规格' })
  specs: JSON;

  @Column({ comment: '商品详情', type: 'text' })
  description: string;
}

@Entity('tb_product_category', {
  comment: '商品分类表',
})
export class ProductCategory {
  @PrimaryGeneratedColumn('increment', { comment: '自增主键', unsigned: true })
  id: number;

  @Column({ comment: '商品名称' })
  name: string;

  @Column({ comment: '是否展示', type: 'tinyint', default: true })
  display: boolean;
}
